﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Activation;
using System.Text;
using ArtWorldObjects;
using WorldOfArtWebApp.DataAccess;

namespace WorldOfArtServiceApp
{
    public class ArtService : IArtService
    {
        protected ArtWorldCollectionArtist artistData;
        protected ArtWorldCollectionArtPiece workOfArtData;
        protected List<Artist> artistList;

        public List<Artist> GetArtists()
        {
            try
            {
                artistList = new List<Artist>();
                artistData = new ArtWorldCollectionArtist();

                if (artistData.ArtWorldCollection.Count > 0 && artistData.ExceptionMessage == string.Empty)
                {
                    foreach (var artist in artistData.ArtWorldCollection)
                    {
                        artist.ExceptionMessage = "No Errors";
                        artistList.Add(artist);
                    }
                }
                else
                {
                    Artist exceptionArtist = new Artist();
                    exceptionArtist.ExceptionMessage = "The artist information you requested is not available: " + artistData.ExceptionMessage;
                    artistList.Add(exceptionArtist);
                }
            }
            catch (Exception ex)
            {
                Artist exCatchArtist = new Artist();
                exCatchArtist.ExceptionMessage = "The artist information you requested is not available: " + ex.Message;
                artistList.Add(exCatchArtist);
            }

            return artistList;
        }
    }
}
